<?php
/** 
 * @author 余风
 * @version 0.1
 * 文件管理类
 * 
 */
class File extends Think {
	private $basePath = '';
	private $fileIo = null;
	public $fileArray = array();
	const SUCCESS = 1;
	const ERROR = 0;
	public function __construct(){
		$this->basePath= UPLOAD_PATH;
		import("@.ORG.Io.Dir");
		$this->fileIo = new Dir($this->basePath);
	}
	
	public function listFile($path = ''){
		if(file_exists($this->basePath.$path)){
			if(isset($path)) $this->fileIo->listFile($this->basePath.$path."/");
			$this->fileArray = $this->fileIo->toArray();
			return self::SUCCESS;
		}else{
			return self::ERROR;
		}
	}
	
	/**
	 * 
	 * 删除目录以及目录下所有的文件
	 * @access public
	 * @param mixed $directory
	 * @return void
	 */
	public function delDir($directory){
		$this->fileIo->delDir($directory);
	}
	
	public function delFile($filePath){
		if(file_exists($filePath)){
			if(unlink($filePath)){
				return true;
			}else{
				return false;
			}
		}else{
			return "该文件不存在";
		}
	}
	
	
}

?>